<?php
namespace app\index\controller;

use app\common\controller\Helptype;
use think\Controller;
use app\index\common;
use think\Db;
use think\Exception;
use think\Paginator;
use think\Session;
use think\Request;
use app\index\controller\Log\InsertLog as IL;
use app\index\controller\Log\OperationLog as OL;
use app\index\controller\Dropdown;
use app\index\controller\Order;
use think\Config;
use app\index\service\OrderService;

/**
 * 通知
 */
class Notice extends Controller
{
    /**
     * [notice_list 通知列表]
     * @DateTime 2018-09-18T15:54:28+0800
     * @刘家腾
     * @return   [type]                   [description]
     */
	public function notice_list(Request $request)
	{
		$postData = $request->post();
        $user_info=Session::get('user');

        $data=array();
        $singlepage=20;
        $page = 1;
        // if($user_info['is_business']==1){
        //     $business_id=$user_info['id'];
        // }else{
        //     $business_id=$this->business_id;
        // }
        $data['state'] = 0;
        if( !empty($postData['page']) ){
            $page = $postData['page'];
        }
        if( !empty($postData['singlepage']) ){
            $singlepage = $postData['singlepage'];
        }
        $data['user_id'] = $user_info['id'];
        $notice_list_datas = $this->notice_list_sql($data,$page,$singlepage);

        return ['code' => 666, 'msg' => "查询成功！", 'data' => $notice_list_datas];
	}
    /**
     * [notice_list_sql 通知列表sql]
     * @DateTime 2018-09-18T15:56:51+0800
     * @刘家腾
     * @param    string                   $page       [description]
     * @param    string                   $singlepage [description]
     * @return   [type]                               [description]
     */
	public function notice_list_sql($data='',$page='',$singlepage='')
    {

       $product_data = Db::table('announcement')
                ->where($data)
                ->paginate($singlepage,false,['query'=>request()->param()])
                ->toArray();
       return $product_data;
    }




}


